<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">   

    <ui:composition template="/templates/interna.xhtml">

	<ui:define name="breadcrumb">

	    <h:form>

		<p:breadCrumb>
		    <p:menuitem value="#{msg.principal}"/>
		    <p:menuitem value="#{msg.menuCadastros}"/>
		    <p:menuitem value="#{msg.subMenuTabelasBasicas}"/>
		    <p:menuitem value="#{msg.subMenuCartorios}"/>
		    <p:menuitem value="#{msg.cartorioCadastrar}" rendered="#{manterCartorio.cartorio.id == null and !manterCartorio.isDetalhamento}"/>
		    <p:menuitem value="#{msg.cartorioEditar}" rendered="#{manterCartorio.cartorio.id != null and !manterCartorio.isDetalhamento}"/>
		    <p:menuitem value="#{msg.cartorioDetalhar}" rendered="#{manterCartorio.isDetalhamento}"/>
		</p:breadCrumb>

	    </h:form>    

	</ui:define>

	<ui:define name="corpo">

	    <h:form >

		<p:fieldset id="fsDadosCartorio" legend="#{msg.cartorioDadosCartorio}" toggleable="true">
		    
		    <h:panelGrid id="pg01" columns="1">
			<p:outputLabel for="itNome" value="#{msg.cartorioNome}"/>
			<p:inputText id="itNome" value="#{manterCartorio.cartorio.nome}" maxlength="120" size="163" required="true" requiredMessage="#{msg.cartorioNome}: #{msg.campo_obrigatorio}" disabled="#{manterCartorio.isDetalhamento}"/>
		    </h:panelGrid>

		    <h:panelGrid id="pg02" columns="4">
			<h:panelGrid columns="1">
			    <p:outputLabel for="itEndereco" value="#{msg.cartorioEndereco}"/>
			    <p:inputText id="itEndereco" value="#{manterCartorio.cartorio.endereco}" maxlength="100" size="50" disabled="#{manterCartorio.isDetalhamento}"/>
			</h:panelGrid>
			<h:panelGrid columns="1">
			    <p:outputLabel for="itBairro" value="#{msg.cartorioBairro}"/>
			    <p:inputText id="itBairro" value="#{manterCartorio.cartorio.bairro}" maxlength="60" size="30" disabled="#{manterCartorio.isDetalhamento}"/>
			</h:panelGrid>
			<h:panelGrid columns="1">
			    <p:outputLabel for="somEstado" value="#{msg.cartorioEstado}"/>
			    <p:selectOneMenu id="somEstado" value="#{manterCartorio.estadoSelecionado}" disabled="#{manterCartorio.isDetalhamento}">
				<f:selectItems value="#{manterCartorio.listaEstados}"/>
				<p:ajax listener="#{manterCartorio.carregarComboMunicipiosPorEstado}" update="somCidade"/>
			    </p:selectOneMenu>
			</h:panelGrid>
			<h:panelGrid columns="1">
			    <p:outputLabel for="somCidade" value="#{msg.cartorioMunicipio}"/>
			    <p:selectOneMenu id="somCidade" value="#{manterCartorio.cartorio.idCidade}" style="width: 240px" disabled="#{manterCartorio.isDetalhamento}">
				<f:selectItems value="#{manterCartorio.listaMunicipios}"/>
			    </p:selectOneMenu>
			</h:panelGrid>			
		    </h:panelGrid>
		    
		    <h:panelGrid id="pg03" columns="3">
			<h:panelGrid columns="1">
			    <p:outputLabel for="itContato" value="#{msg.cartorioContato}"/>
			    <p:inputText id="itContato" value="#{manterCartorio.cartorio.contato}" maxlength="60" size="98" disabled="#{manterCartorio.isDetalhamento}"/>
			</h:panelGrid>
			<h:panelGrid columns="1">
			    <p:outputLabel for="itTelefone" value="#{msg.cartorioTelefone}"/>
			    <p:inputMask id="itTelefone" mask="(99)9999-9999" value="#{manterCartorio.cartorio.telefone}" size="25" disabled="#{manterCartorio.isDetalhamento}"/>
			</h:panelGrid>
			<h:panelGrid columns="1">
			    <p:outputLabel for="itFax" value="#{msg.cartorioFax}"/>
			    <p:inputMask id="itFax" mask="(99)9999-9999" value="#{manterCartorio.cartorio.fax}" size="25" disabled="#{manterCartorio.isDetalhamento}"/>
			</h:panelGrid>			
		    </h:panelGrid>

		</p:fieldset>

		<div class="espacamento"/>

		<div align="left">
		    <p:commandButton value="#{msg.novo}" 
				     icon="ui-icon-plusthick" 
				     ajax="false"
				     immediate="true"
				     rendered="#{manterCartorio.isDetalhamento}"
				     action="#{manterCartorio.setup()}"/>
		    <p:spacer width="5" rendered="#{manterCartorio.isDetalhamento}"/>
		    <p:commandButton value="#{msg.editar}" 
				     icon="ui-icon-clipboard" 
				     ajax="false"
				     immediate="true"
				     rendered="#{manterCartorio.isDetalhamento}">
			<f:setPropertyActionListener value="false" target="#{manterCartorio.isDetalhamento}"/>
		    </p:commandButton>
		    <p:spacer width="5" rendered="#{manterCartorio.isDetalhamento}"/>
		    <p:commandButton value="#{msg.salvar}" 
				     icon="ui-icon-disk" 
				     ajax="false"
				     rendered="#{!manterCartorio.isDetalhamento}"
				     action="#{manterCartorio.salvar}"/>
		    <p:spacer width="5" rendered="#{!manterCartorio.isDetalhamento}"/>
		    <p:commandButton value="#{msg.cancelar}" 
				     icon="ui-icon-closethick"
				     immediate="true"
				     rendered="#{!manterCartorio.isDetalhamento}"
				     onclick="pnConfirmacao.show();">
			<f:setPropertyActionListener value="#{manterCartorio.cartorio.id}" target="#{manterCartorio.idEmpreendimento}"/>
		    </p:commandButton>	
		    <p:spacer width="5" rendered="#{!manterCartorio.isDetalhamento}"/>
		    <p:commandButton value="#{msg.voltar}" 
				     action="#{manterCartorio.voltar}" 
				     icon="ui-icon-arrowreturnthick-1-w"
				     ajax="false"
				     immediate="true"/>	
		</div>
		
		<ui:include src="/restrito/painel_confirmacao.xhtml">
		    <ui:param name="id" value="pnConfirmacao"/>
		    <ui:param name="mensagem" value="#{msg.deseja_cancelar_operacao}"/>
		    <ui:param name="bean" value="#{manterCartorio}"/>
		    <ui:param name="action" value="#{manterCartorio.cartorio.id != null ? 'detalhar' : 'setup'}"/>
		</ui:include>

	    </h:form>

	</ui:define>

    </ui:composition>

</html>
